import path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default ({ mode }) => {
  let base = '/';

  if (mode === 'development') {
    base = '/mine/';
  }

  // https://vitejs.dev/config/
  return defineConfig({
    base,
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src')
      }
    },
    css: {
      preprocessorOptions: {
        less: {
          rootpath: base,
          // 注入 Less 变量
          // globalVars: {
          //   'image-path': base,
          // }
        }
      }
    },
    plugins: [react()],
  });
}
